package com.smart.campus.web.controller.school;

import com.smart.campus.common.core.controller.BaseController;
import com.smart.campus.common.core.page.TableDataInfo;
import com.smart.campus.school.domain.Student;
import com.smart.campus.system.domain.SysUser;
import com.smart.campus.system.service.ISysUserService;
import com.smart.campus.web.utils.SchoolUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.Collator;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@Controller("teacher")
@RequestMapping("/school/teacher")
public class TeacherController extends BaseController {


    @Autowired
    private ISysUserService sysUserService;

    /**
     * 获取老师
     */
    @PostMapping("/getTeacherList")
    @ResponseBody
    public List<SysUser> getTeacherList()
    {
        SysUser user = new SysUser();
        user.setDeptId(SchoolUtil.getSchoolId());

        List<SysUser> list = sysUserService.selectUserList(user);
        list = list.stream().sorted((user1, user2) -> {
            Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
            return cmp.compare(user1.getUserName(), user2.getUserName());
        }).collect(Collectors.toList());
        return list;
    }

}
